From: theanarkh Date: Sat, 5 Jul 2025 17:33:23 +0000 (+0800) Subject: [PATCH] os: fix GetInterfaceAddresses memory lieaky X-Git-Tag: archive/raspbian/20.19.2+dfsg-1+rpi1+deb13u2^2~20 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/success//%22mailto:hdevalence%40gmail.com/%22/%22http:/www.example.com/cgi/success/%22mailto:hdevalence%40gmail.com/%22?a=commitdiff_plain;h=18ca3b6a58e94f246dfb81346be120789cc76dd2;p=nodejs.git [PATCH] os: fix GetInterfaceAddresses memory lieaky PR-URL: https://github.com/nodejs/node/pull/58940 Reviewed-By: Juan José Arboleda Reviewed-By: Chengzhong Wu Gbp-Pq: Topic sec Gbp-Pq: Name 15-fix-os-getinterface-addresses-leak.patch --- diff --git a/src/node_os.cc b/src/node_os.cc index ce2af8d83..ddaf61d5e 100644 --- a/src/node_os.cc +++ b/src/node_os.cc @@ -192,6 +192,9 @@ static void GetInterfaceAddresses(const FunctionCallbackInfo& args) { return args.GetReturnValue().SetUndefined(); } + auto cleanup = + OnScopeLeave([&]() { uv_free_interface_addresses(interfaces, count); }); + Local no_scope_id = Integer::New(isolate, -1); std::vector> result; result.reserve(count * 7); @@ -243,7 +246,6 @@ static void GetInterfaceAddresses(const FunctionCallbackInfo& args) { } } - uv_free_interface_addresses(interfaces, count); args.GetReturnValue().Set(Array::New(isolate, result.data(), result.size())); }